// 源插件
import React, { PureComponent } from 'react';
// 视图插件
import { Spin, Empty } from 'antd';

// 外部组件

// css OR less预编译器

// 图片

class Loading extends PureComponent {
  componentWillMount() {}

  /**
   *  Describe:当前状态
   *  Created by xjc on 2019/5/15
   */

  state = {
    flag: true,
  };

  /**
   *  Describe:视图
   *  Created by xjc on 2019/5/15
   */

  render() {
    return this.state.flag === true ? (
      <div
        style={{
          borderRadius: 4,
          paddingTop: 100,
          paddingBottom: 100,
          textAlign: 'center',
          margin: '20 20',
        }}
      >
        <Spin size="large" />
      </div>
    ) : (
      <Empty />
    );
  }

  componentDidMount() {
    const { time } = this.props;
    window.timer = setTimeout(() => {
      this.setState({
        flag: false,
      });
    }, time || 6000);
  }

  componentWillUnmount() {
    window.clearInterval(window.timer);
  }
}

export default Loading;
